package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Role;
import com.zzyl.vo.RoleVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface RoleMapper {
    /**
     * 分页查询
     * @param roleName
     * @return
     */
    Page<RoleVo> selectPage(String roleName);

    /**
     * 新增
     * @param role
     */
    @Insert("insert into sys_role (role_name, label, sort_no, create_time, update_time, remark, create_by, update_by) " +
            "VALUES (#{roleName},#{label},#{sortNo},#{createTime},#{updateTime},#{remark},#{createBy},#{updateBy}) ")
    void insert(Role role);

    /**
     * 根据roleId查询
     * @param roleId
     * @return
     */
    @Select("select * from sys_role where id = #{roleId}")
    Role getById(Long roleId);

    /**
     * 删除角色
     * @param roleId
     */
    @Delete("delete from sys_role where id = #{roleId}")
    void deleteByRoleId(Long roleId);

    /**
     * 更新
     * @param role
     * @return
     */
    Boolean update(Role role);

    /**
     * 获取所有的角色
     * @return
     */
    @Select("select * from sys_role")
    List<RoleVo> getAllRoles();
}
